package com.demo.service;

import com.demo.dto.MessageDTo;
import com.demo.pojo.CommonResponseVo;

/**
 * @author oyz
 */
public class SMSServiceImpl extends AbstractMsgService implements MsgService {
    @Override
    public CommonResponseVo sendMsg(MessageDTo messageDTo) {
        MsgService service = super.chioce(messageDTo);
        CommonResponseVo responseVo;
        if (service instanceof SMSServiceImpl) {
            responseVo = sendSMS(messageDTo);
            if (!"0".equals(responseVo.getFlag())) {
                // 发送站内消息
                messageDTo.setMsgType("INTERNAL_MSG");
                MsgService internalMsg = super.chioce(messageDTo);
                responseVo = internalMsg.sendMsg(messageDTo);
            }
            return responseVo;
        }
        return null;
    }

    @Override
    protected CommonResponseVo sendSMS(MessageDTo messageDTo) {
        notify(messageDTo);
        return null;
    }
}
